﻿using CommunityToolkit.Mvvm.ComponentModel;
using System.Collections.ObjectModel;

namespace KxApp.Chart
{
    public partial class KxDevice : ObservableObject, IBaseParameter
    {
        public int Id { get; set; }
        public bool IsDelete { get; set; }
        public int DeviceNum { get; set; }
        public string? DeviceName { get; set; } = string.Empty;


        //public int State { get; set; }
        public string? AlarmInfo { get; set; } = string.Empty;


        private int state;

        public int State
        {
            get { return state; }
            set
            {
                bool a = SetProperty(ref state, value);
                if (a)
                {
                    if (DeviceName == "搬运机器人")
                    {
                        if (value == 2)
                        {
                            StateStr = "111111";
                        }
                        if (value == 1)
                        {
                            StateStr = "自动";
                        }
                        if (value == 3)
                        {
                            StateStr = "停机";
                        }
                        if (value == 4)
                        {
                            StateStr = "离线";
                        }
                    }
                    else if (DeviceName == "立式加工中心")
                    {
                        if (value == 2)
                        {
                            StateStr = "手动";
                        }
                        if (value == 1)
                        {
                            StateStr = "自动";
                        }
                        if (value == 3)
                        {
                            StateStr = "停机";
                        }
                        if (value == 4)
                        {
                            StateStr = "离线";
                        }
                    }
                    else
                    {
                        if (value == 2)
                        {
                            StateStr = "手动";
                        }
                        if (value == 1)
                        {
                            StateStr = "自动";
                        }
                        if (value == 3)
                        {
                            StateStr = "停机";
                        }
                        if (value == 4)
                        {
                            StateStr = "离线";
                        }
                    }

                }
            }
        }

        private string stateStr = "";
        /// <summary>
        /// 转换器
        /// </summary>
        public string StateStr
        {
            get { return stateStr; }
            set
            {
                bool a = SetProperty(ref stateStr, value);
            }
        }

        [ObservableProperty]
        private double dviceRunTime;
        public ObservableCollection<Variable>? Variables { get; set; } = new();


    }
}
